/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.stream.Stream;

/**
 * <p>Project: javaseapp - Stream4
 * <p>Powered by webrx On 2021-08-23 11:42:53
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Stream4 {
    public static void main(String[] args) {
        var sms = Stream.of("c", "java", "go", "ruby", "python", "php", "javascript", "sql");

        //按字符个数，进行排序
        //sms.sorted((a, b) -> b.length() - a.length()).forEach(System.out::println);

        var smstu = Stream.of(new Student(1, "jack", 80), new Student(3, "andy", 90));
        //对象，按成绩大小降序
        //smstu.sorted((a, b) -> b.getScore() - a.getScore()).forEach(System.out::println);
        // map() 90 80
        //smstu.sorted((a, b) -> b.getScore() - a.getScore()).map(Student::getScore).forEach(System.out::println);
        smstu.sorted((a, b) -> b.getScore() - a.getScore()).peek(Student::getScore).forEach(System.out::println);
    }
}
